<?php

/**
 * This is the model class for table "prefix_invite".
 *
 * The followings are the available columns in table 'prefix_invite':
 * @property string $invite_id
 * @property string $invite_code
 * @property string $user_from_id
 * @property string $user_to_id
 * @property string $invite_date_add
 * @property string $invite_date_used
 * @property integer $invite_used
 * @property User $fromUser
 * @property User $toUser
 */
class Invite extends LsActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Invite the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return Config::Get('db.table.invite');
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('invite_code, user_from_id, invite_date_add', 'required'),
			array('invite_used', 'numerical', 'integerOnly'=>true),
			array('invite_code', 'length', 'max'=>32),
			array('user_from_id, user_to_id', 'length', 'max'=>11),
			array('invite_date_used', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('invite_id, invite_code, user_from_id, user_to_id, invite_date_add, invite_date_used, invite_used', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'fromUser' => array(self::BELONGS_TO, 'User', 'user_from_id'),
			'toUser' => array(self::BELONGS_TO, 'User', 'user_to_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'invite_id' => 'Invite',
			'invite_code' => 'Invite Code',
			'user_from_id' => 'User From',
			'user_to_id' => 'User To',
			'invite_date_add' => 'Invite Date Add',
			'invite_date_used' => 'Invite Date Used',
			'invite_used' => 'Invite Used',
		);
	}

	
}